package com.shengjing.apk;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;

import pl.droidsonroids.gif.GifImageView;

public class WelcomeActivity extends Activity {
    private Handler mHandler = new Handler();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_welcome);
        GifImageView gifView1 = (GifImageView) findViewById(R.id.gif1);
        mHandler.postDelayed(mJumpRunable, 3000);
    }

    Runnable mJumpRunable = new Runnable() {
        @Override
        public void run() {
            SharedPreferences sf = getSharedPreferences("data", MODE_PRIVATE);//判断是否是第一次进入
            boolean isFirstIn = sf.getBoolean("isFirstIn", true) || !BuildConfig.DEBUG;
            SharedPreferences.Editor editor = sf.edit();
            if (isFirstIn) {     //若为true，则是第一次进入
                editor.putBoolean("isFirstIn", false);
                goGuide();
            } else {
                goMain();
            }
            editor.commit();
        }
    };

    private void goMain() {
        Intent intent = new Intent(WelcomeActivity.this, MainActivity.class);
        startActivity(intent);
        finish();

    }

    private void goGuide() {
        Intent intent = new Intent(
                WelcomeActivity.this, GuideActivity.class);
        startActivity(intent);
        finish();
    }

    @Override
    public void onBackPressed() {
//        super.onBackPressed();
    }
}